<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="common/header.jsp"%>
<div class="clearfix"></div>
<div class="row">
  <div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
      <div class="x_title">
        <h2>新增APP基础信息 <i class="fa fa-user"></i><small>${devUser.devname}</small></h2>
             <div class="clearfix"></div>
      </div>
      <div class="x_content">
           <div class="clearfix"></div>
           <center style="font-size: 24px;">${info}</center>
        <form class="form-horizontal form-label-left"
              action="${pageContext.request.contextPath}/addAppInfo"
              method="post" enctype="multipart/form-data">
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">软件名称 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="softwareName" class="form-control col-md-7 col-xs-12" 
               data-validate-length-range="20" data-validate-words="1" name="softwarename"  required="required"
               placeholder="请输入软件名称" type="text">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">APK名称 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="APKName" class="form-control col-md-7 col-xs-12" 
              	data-validate-length-range="20" data-validate-words="1" name="apkname"   required="required"
              	placeholder="请输入APK名称" type="text">
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">支持ROM <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="supportROM" class="form-control col-md-7 col-xs-12" name="supportrom"
              	data-validate-length-range="20" data-validate-words="1"   required="required"
              	placeholder="请输入支持的ROM" type="text">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">界面语言 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="interfaceLanguage" class="form-control col-md-7 col-xs-12" 
              data-validate-length-range="20" data-validate-words="1" name="interfacelanguage"   required="required"
              placeholder="请输入软件支持的界面语言" type="text">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="number">软件大小 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="number" id="softwareSize" name="softwaresize"   required="required" onkeyup="value=value.replace(/[^\d]/g,'')"
              data-validate-minmax="10,500"  placeholder="请输入软件大小，单位为Mb" class="form-control col-md-7 col-xs-12">
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="number">下载次数 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="number" id="downloads" name="downloads"   required="required"
              data-validate-minmax="10,500"  placeholder="请输入下载次数" class="form-control col-md-7 col-xs-12">
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12"  for="select">所属平台 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <select name="flatformid" id="flatformId" class="form-control"   required="required">
                <option value="">--请选择--</option>
              </select>
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="select">一级分类 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <select name="categorylevel1" id="categoryLevel1" class="form-control"   required="required">
                <option value="">--请选择--</option>
              </select>
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12"  for="select">二级分类 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <select name="categorylevel2" id="categoryLevel2" class="form-control"  required="required">
                <option value="">--请选择--</option>
              </select>
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="select">三级分类 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <select name="categorylevel3" id="categoryLevel3" class="form-control"  required="required">
                <option value="">--请选择--</option>
              </select>
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">APP状态 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
            	<input type="hidden" name="status" id="status" value="1">待审核 [放了一个隐藏域:默认给了值为:1]
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">应用简介 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <textarea id="appInfo" name="appinfo"     required="required"
              placeholder="请输入本软件的相关信息，本信息作为软件的详细信息进行软件的介绍。" class="form-control col-md-7 col-xs-12"></textarea>
            </div>
          </div>
           <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">LOGO图片 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
            <input type="file" class="form-control col-md-7 col-xs-12" name="a_logoPicPath"  required="required" id="a_logoPicPath"/>
            </div>
          </div>
          <div class="ln_solid"></div>
          <div class="form-group">
            <div class="col-md-6 col-md-offset-3">
              <button id="send" type="submit" class="btn btn-success">保存</button>
              <button type="button" class="btn btn-primary" id="back">返回</button>
              <br/><br/>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<%@include file="common/footer.jsp"%>
<script language="JavaScript">
    $(function(){   //加载事件
        //2.发送异步请求加载平台分类
        $.post("${pageContext.request.contextPath}/getFlatform",null,function (data) {
            for (var j=0;j<data.length;j++){
                var option=$("<option value='"+data[j].valueid+"'>"+data[j].valuename+"</option>");
                $("#flatformId").append(option);
            }
        },"json");

        //3.发送异步请求加载一级分类...
        $.post("${pageContext.request.contextPath}/getCategory",null,function (data) {
            //动态加载下拉列表的选项
            for (var i=0;i<data.length;i++){
                var node=$("<option value='"+data[i].id+"'>"+data[i].categoryname+"</option>");
                //将node添加到select标签中   添加子节点
                $("#categoryLevel1").append(node);
            }
        },"json");


        // 二级分类的数据
        //4.当选择一级分类时，触发onchange事件，加载二级分类
        $("#categoryLevel1").change(loadCategoryLevel2);

        function loadCategoryLevel2() {
            //4.1获取一级分类的值
            var parentId=$("#categoryLevel1").val();

            $("#categoryLevel2>option:gt(0)").remove();  //清空原有的下拉列表项
            $("#categoryLevel3>option:gt(0)").remove();
            if (parentId!=""){

                //4.2发送异步请求通过分类的id查询子类
                //参数的格式:{"请求参数名称":参数值,"请求参数名称":参数值...}
                $.post("${pageContext.request.contextPath}/getCategory",{"id":parentId},function (data) {
                    //动态加载下拉列表的选项
                    for (var i=0;i<data.length;i++){
                        var node=$("<option value='"+data[i].id+"'>"+data[i].categoryname+"</option>");
                        //将node添加到select标签中   添加子节点
                        $("#categoryLevel2").append(node);
                    }
                },"json");
            }
        }

        //加载三级分类的数据
        $("#categoryLevel2").change(loadCategoryLevel3);
        function loadCategoryLevel3() {
            //4.1获取二级级分类的值
            var parentId=$("#categoryLevel2").val();
            $("#categoryLevel3>option:gt(0)").remove();  //清空原有的下拉列表项
            if (parentId!=""){
                //4.2发送异步请求通过分类的id查询子类
                $.post("${pageContext.request.contextPath}/getCategory",{"id":parentId},function (data) {
                    //动态加载下拉列表的选项
                    for (var i=0;i<data.length;i++){
                        var node=$("<option value='"+data[i].id+"'>"+data[i].categoryname+"</option>");
                        //将node添加到select标签中   添加子节点
                        $("#categoryLevel3").append(node);
                    }
                },"json");
            }
        }
    });
</script>
